package com.example.charge.controller;

import com.example.bill.vo.BillVo;
import com.example.charge.service.ChargeService;
import com.example.charge.vo.ChargeVo;
import com.example.result.CommonResult;
import com.example.utils.MyPageHelper;
import com.example.utils.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/charge")
public class ChargeController {
    @Autowired
    ChargeService chargeService;
    /**
     * 收费管理-收费项目管理全查
     * @return
     */
    @GetMapping("/getCharge")
    public CommonResult getCharge(@RequestParam Integer chargeChargeMode, PageRequest pageRequest){
        MyPageHelper.StartPage(pageRequest);
        CommonResult commonResult = chargeService.getCharge(chargeChargeMode);
        return commonResult;
    }
    /**
     * 收费管理-收费项目管理删除
     */
    @DeleteMapping("/delCharge")
    public CommonResult delArea(Integer id){
        int i = chargeService.delCharge(id);
        return CommonResult.ok(i);
    }
    /**
     * 收费管理-收费项目管理增改
     */
    @PostMapping("/saveOrUpdateCharge")
    public CommonResult saveOrUpdateCharge(@RequestBody ChargeVo chargeVo){
        int i = chargeService.saveOrUpdateCharge(chargeVo);
        if(i>0){
            return CommonResult.ok();
        }else{
            return CommonResult.fail();
        }
    }
}
